using UnityEngine;
using System.Collections;

public class Launcher : MonoBehaviour {

	public GameObject tiro;
	public float forca = 500;
    public int n_tiro;
    public int nmax_tiro = 5;
    public float t_recarga = 3;
	
	// Use this for initialization
	void Start () {
        n_tiro = nmax_tiro;
	}
	
	// Update is called once per frame
	void Update () {
		if(Input.GetKeyDown(KeyCode.Space) && n_tiro>0)
		{
			Atirar();
		}
	}
	
	private void Atirar()
	{
		Instantiate(tiro, this.transform.position, tiro.transform.rotation);
		tiro.rigidbody.AddForce(this.transform.forward*forca);
        n_tiro--;
	}
}
